package com.edu.order.feign;

import com.edu.order.feign.fallback.ProductFeignClientFallback;
import com.edu.product.bean.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Component("productFeignClient")
// Feign客户端，自动负载均衡
@FeignClient(value = "service-product", fallback = ProductFeignClientFallback.class)
public interface ProductFeignClient {
    /**
     * MVC注解的两套使用逻辑
     * 1. 标注在 Controller 上，是接受这样的请求
     * 2. 标注在 FeignClient 上，是发送这样的请求
     *
     * @return
     */
    @GetMapping("/product/{id}")
    Product getProductById(@PathVariable("id") Long id);
}
